package manger;

import org.junit.Test;
import service.WxService;

import javax.rmi.CORBA.Util;

/**
 * Created by Administrator on 2019/1/23.
 */
public class TemplateMessageManger {

    //设置行业
    @Test
//    public void set(){
//        String url="https://api.weixin.qq.com/cgi-bin/template/api_set_industry?access_token=ACCESS_TOKEN";
//         url = url.replace("ACCESS_TOKEN", WxService.getAccessToken());
//
//         String data= "{\n" +
//                 "          \"industry_id1\":\"1\",\n" +
//                 "          \"industry_id2\":\"4\"\n" +
//                 "       }";
//
//        String result = util.Util.post(url,data);
//
//        System.out.println(result);
//    }

    //获取行业
//    public void get(){
//        String tk = WxService.getAccessToken();
//        String url="https://api.weixin.qq.com/cgi-bin/template/get_industry?access_token="+tk;
//        String result = util.Util.get(url);
//        System.out.println(result);
//
//    }


//    public void  sendTemplateMessage(){
//
//        String tk = WxService.getAccessToken();
//        String url="https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="+tk;
//        String data = " {\n" +
//                "           \"touser\":\"oNtt61NXCAoROt2URP5UU5D8pFpI\",\n" +
//                "           \"template_id\":\"TvICGBu-iSSZvGDT1AD5ziAbEkZfEnUzqBt0g167z9k\",\n" +
//                "           \"data\":{\n" +
//                "                   \"first\": {\n" +
//                "                       \"value\":\"刘家明巨帅！\",\n" +
//                "                       \"color\":\"#173177\"\n" +
//                "                   },\n" +
//                "                   \"company\":{\n" +
//                "                       \"value\":\"刘家明超帅\",\n" +
//                "                       \"color\":\"#173177\"\n" +
//                "                   },\n" +
//                "                   \"time\": {\n" +
//                "                       \"value\":\"刘家明日帅\",\n" +
//                "                       \"color\":\"#173177\"\n" +
//                "                   },\n" +
//                "                   \"result\": {\n" +
//                "                       \"value\":\"刘家明怎么这么帅\",\n" +
//                "                       \"color\":\"#173177\"\n" +
//                "                   },\n" +
//                "                   \"remark\":{\n" +
//                "                       \"value\":\"刘家明太帅！\",\n" +
//                "                       \"color\":\"#173177\"\n" +
//                "                   }\n" +
//                "           }\n" +
//                "       }";
//        String result = util.Util.post(url,data);
//        System.out.print(result);
//    }


    public void  sendTemplateMessage2(){

        String tk = WxService.getAccessToken();
        String url="https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="+tk;
        String data = " {\n" +
                "           \"touser\":\"oNtt61DGIWY7cCo9TPsZC5rBzsfw\",\n" +
                "           \"template_id\":\"BGGBecCQRqrOI9CeA1_GJSbJESzxrn1V95y-ZXCE5Ac\",\n" +
                "           \"data\":{\n" +
                "                   \"first\": {\n" +
                "                       \"value\":\"刘家明巨帅！\",\n" +
                "                       \"color\":\"#173177\"\n" +
                "                   },\n" +
                "                   \"keyword1\":{\n" +
                "                       \"value\":\"10086\",\n" +
                "                       \"color\":\"#173177\"\n" +
                "                   },\n" +
                "                   \"keyword2\": {\n" +
                "                       \"value\":\"￥-1000000000000\",\n" +
                "                       \"color\":\"#173177\"\n" +
                "                   },\n" +
                "                   \"keyword3\": {\n" +
                "                       \"value\":\"成功，不交钱的话，就发律师函\",\n" +
                "                       \"color\":\"#173177\"\n" +
                "                   },\n" +
                "                   \"remark\":{\n" +
                "                       \"value\":\"刘家明太帅！\",\n" +
                "                       \"color\":\"#173177\"\n" +
                "                   }\n" +
                "           }\n" +
                "       }";
        String result = util.Util.post(url,data);
        System.out.print(result);
    }
}
